package com.neusiri.controller;

import com.neusiri.entity.LoginRespEntity;
import com.neusiri.entity.SysUserEntity;
import com.neusiri.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * UserController
 *
 * @author 丛有志
 * @date 2020/11/6 15:12
 * <p>
 * 版本        修改时间        作者        修改内容
 * V1.0        2020/11/6     丛有志        初始版本
 */
@Slf4j
@RestController
@RequestMapping("/api")
public class UserController {

    @Resource
    private UserService userService;

    /**
     * 获取验证码
     *
     * @param phoneNumber 手机号码
     * @return 验证码
     */
    @PostMapping("/getPicCode")
    public String getPicCode(String phoneNumber) {
        return userService.getPicCode(phoneNumber);
    }

    /**
     * 登录
     *
     * @param sysUserEntity 用户信息
     * @return 登录信息
     */
    @GetMapping("/user/login")
    public LoginRespEntity login(@RequestBody SysUserEntity sysUserEntity) {
        return userService.login(sysUserEntity);
    }

    /**
     * 注册
     *
     * @param sysUserEntity 用户信息
     * @return 是否注册成功
     */
    @PostMapping("/user/register")
    public String register(@RequestBody SysUserEntity sysUserEntity) {
        return userService.register(sysUserEntity);
    }

    /**
     * 查询人员列表
     *
     * @return 人员列表
     */
    @GetMapping("/user/getUserInfo")
    public List<SysUserEntity> getUserInfoList() {
        return userService.getUserInfoList();
    }
}


